home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / easyno1a / frmmain.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-04  |  33.3 KB  |  981 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.2#0"; "RICHTX32.OCX"
  5. Begin VB.Form frmMain 
  6.    Caption         =   "Easy Note-Pad"
  7.    ClientHeight    =   6435
  8.    ClientLeft      =   165
  9.    ClientTop       =   735
  10.    ClientWidth     =   9090
  11.    Icon            =   "frmMain.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    ScaleHeight     =   6435
  15.    ScaleWidth      =   9090
  16.    StartUpPosition =   3  'Windows Default
  17.    Begin RichTextLib.RichTextBox RichTextBox1 
  18.       Height          =   2430
  19.       Left            =   0
  20.       TabIndex        =   2
  21.       Top             =   2625
  22.       Width           =   1485
  23.       _ExtentX        =   2619
  24.       _ExtentY        =   4286
  25.       _Version        =   393217
  26.       BorderStyle     =   0
  27.       Enabled         =   -1  'True
  28.       HideSelection   =   0   'False
  29.       ScrollBars      =   3
  30.       TextRTF         =   $"frmMain.frx":0442
  31.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  32.          Name            =   "Arial"
  33.          Size            =   9.75
  34.          Charset         =   0
  35.          Weight          =   400
  36.          Underline       =   0   'False
  37.          Italic          =   0   'False
  38.          Strikethrough   =   0   'False
  39.       EndProperty
  40.    End
  41.    Begin MSComctlLib.Toolbar tbToolBar 
  42.       Align           =   1  'Align Top
  43.       Height          =   360
  44.       Left            =   0
  45.       TabIndex        =   1
  46.       Top             =   0
  47.       Width           =   9090
  48.       _ExtentX        =   16034
  49.       _ExtentY        =   635
  50.       ButtonWidth     =   609
  51.       ButtonHeight    =   582
  52.       Appearance      =   1
  53.       Style           =   1
  54.       ImageList       =   "imlToolbarIcons"
  55.       _Version        =   393216
  56.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  57.          NumButtons      =   21
  58.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  59.             Key             =   "New"
  60.             Description     =   "Create a new file."
  61.             Object.ToolTipText     =   "New"
  62.             ImageKey        =   "New"
  63.          EndProperty
  64.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  65.             Key             =   "Open"
  66.             Description     =   "Open existing file."
  67.             Object.ToolTipText     =   "Open"
  68.             ImageKey        =   "Open"
  69.          EndProperty
  70.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  71.             Key             =   "Save"
  72.             Description     =   "Save current file"
  73.             Object.ToolTipText     =   "Save"
  74.             ImageKey        =   "Save"
  75.          EndProperty
  76.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  77.             Style           =   3
  78.          EndProperty
  79.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  80.             Key             =   "Print"
  81.             Description     =   "Print current file."
  82.             Object.ToolTipText     =   "Print"
  83.             ImageKey        =   "Print"
  84.          EndProperty
  85.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  86.             Style           =   3
  87.          EndProperty
  88.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  89.             Key             =   "Cut"
  90.             Description     =   "Cut selected text."
  91.             Object.ToolTipText     =   "Cut"
  92.             ImageKey        =   "Cut"
  93.          EndProperty
  94.          BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  95.             Key             =   "Copy"
  96.             Description     =   "Copy to clipboard."
  97.             Object.ToolTipText     =   "Copy"
  98.             ImageKey        =   "Copy"
  99.          EndProperty
  100.          BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  101.             Key             =   "Paste"
  102.             Description     =   "Paste from clipboard."
  103.             Object.ToolTipText     =   "Paste"
  104.             ImageKey        =   "Paste"
  105.          EndProperty
  106.          BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  107.             Style           =   3
  108.          EndProperty
  109.          BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  110.             Key             =   "Delete"
  111.             Description     =   "Delete selected text."
  112.             Object.ToolTipText     =   "Delete"
  113.             ImageKey        =   "Delete"
  114.          EndProperty
  115.          BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  116.             Style           =   3
  117.          EndProperty
  118.          BeginProperty Button13 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  119.             Key             =   "Bold"
  120.             Description     =   "Bold font."
  121.             Object.ToolTipText     =   "Bold"
  122.             ImageKey        =   "Bold"
  123.             Style           =   1
  124.          EndProperty
  125.          BeginProperty Button14 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  126.             Key             =   "Italic"
  127.             Description     =   "Italic font."
  128.             Object.ToolTipText     =   "Italic"
  129.             ImageKey        =   "Italic"
  130.             Style           =   1
  131.          EndProperty
  132.          BeginProperty Button15 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  133.             Key             =   "Underline"
  134.             Description     =   "Underline font."
  135.             Object.ToolTipText     =   "Underline"
  136.             ImageKey        =   "Underline"
  137.             Style           =   1
  138.          EndProperty
  139.          BeginProperty Button16 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  140.             Style           =   3
  141.          EndProperty
  142.          BeginProperty Button17 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  143.             Key             =   "Find"
  144.             Description     =   "Find text in document."
  145.             Object.ToolTipText     =   "Find"
  146.             ImageKey        =   "Find"
  147.          EndProperty
  148.          BeginProperty Button18 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  149.             Style           =   3
  150.          EndProperty
  151.          BeginProperty Button19 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  152.             Key             =   "Align Left"
  153.             Description     =   "Align text left."
  154.             Object.ToolTipText     =   "Align Left"
  155.             ImageKey        =   "Align Left"
  156.             Style           =   2
  157.          EndProperty
  158.          BeginProperty Button20 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  159.             Key             =   "Center"
  160.             Description     =   "Align text center."
  161.             Object.ToolTipText     =   "Center"
  162.             ImageKey        =   "Center"
  163.             Style           =   2
  164.          EndProperty
  165.          BeginProperty Button21 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  166.             Key             =   "Align Right"
  167.             Description     =   "Align text right."
  168.             Object.ToolTipText     =   "Align Right"
  169.             ImageKey        =   "Align Right"
  170.             Style           =   2
  171.          EndProperty
  172.       EndProperty
  173.    End
  174.    Begin MSComctlLib.StatusBar sbStatusBar 
  175.       Align           =   2  'Align Bottom
  176.       Height          =   270
  177.       Left            =   0
  178.       TabIndex        =   0
  179.       Top             =   6165
  180.       Width           =   9090
  181.       _ExtentX        =   16034
  182.       _ExtentY        =   476
  183.       _Version        =   393216
  184.       BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
  185.          NumPanels       =   7
  186.          BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  187.             AutoSize        =   1
  188.             Object.Width           =   6853
  189.          EndProperty
  190.          BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  191.             Style           =   1
  192.             Alignment       =   1
  193.             AutoSize        =   2
  194.             Enabled         =   0   'False
  195.             Object.Width           =   1244
  196.             MinWidth        =   1235
  197.             TextSave        =   "CAPS"
  198.          EndProperty
  199.          BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  200.             Style           =   2
  201.             Alignment       =   1
  202.             AutoSize        =   2
  203.             Object.Width           =   1244
  204.             MinWidth        =   1235
  205.             TextSave        =   "NUM"
  206.          EndProperty
  207.          BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  208.             Style           =   3
  209.             Alignment       =   1
  210.             AutoSize        =   2
  211.             Enabled         =   0   'False
  212.             Object.Width           =   1244
  213.             MinWidth        =   1235
  214.             TextSave        =   "INS"
  215.          EndProperty
  216.          BeginProperty Panel5 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  217.             Style           =   4
  218.             Alignment       =   1
  219.             AutoSize        =   2
  220.             Enabled         =   0   'False
  221.             Object.Width           =   1244
  222.             MinWidth        =   1235
  223.             TextSave        =   "SCRL"
  224.          EndProperty
  225.          BeginProperty Panel6 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  226.             Style           =   6
  227.             Alignment       =   1
  228.             AutoSize        =   2
  229.             Object.Width           =   1773
  230.             MinWidth        =   1764
  231.             TextSave        =   "9/4/99"
  232.          EndProperty
  233.          BeginProperty Panel7 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
  234.             Style           =   5
  235.             Alignment       =   1
  236.             AutoSize        =   2
  237.             Object.Width           =   1773
  238.             MinWidth        =   1764
  239.             TextSave        =   "6:24 PM"
  240.          EndProperty
  241.       EndProperty
  242.    End
  243.    Begin MSComDlg.CommonDialog CDL1 
  244.       Left            =   1575
  245.       Top             =   3885
  246.       _ExtentX        =   847
  247.       _ExtentY        =   847
  248.       _Version        =   393216
  249.    End
  250.    Begin MSComctlLib.ImageList imlToolbarIcons 
  251.       Left            =   1575
  252.       Top             =   4410
  253.       _ExtentX        =   1005
  254.       _ExtentY        =   1005
  255.       BackColor       =   -2147483643
  256.       ImageWidth      =   16
  257.       ImageHeight     =   16
  258.       MaskColor       =   12632256
  259.       _Version        =   393216
  260.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  261.          NumListImages   =   16
  262.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  263.             Picture         =   "frmMain.frx":050F
  264.             Key             =   "New"
  265.          EndProperty
  266.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  267.             Picture         =   "frmMain.frx":0621
  268.             Key             =   "Open"
  269.          EndProperty
  270.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  271.             Picture         =   "frmMain.frx":0733
  272.             Key             =   "Save"
  273.          EndProperty
  274.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  275.             Picture         =   "frmMain.frx":0845
  276.             Key             =   "Print"
  277.          EndProperty
  278.          BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  279.             Picture         =   "frmMain.frx":0957
  280.             Key             =   "Cut"
  281.          EndProperty
  282.          BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  283.             Picture         =   "frmMain.frx":0A69
  284.             Key             =   "Copy"
  285.          EndProperty
  286.          BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  287.             Picture         =   "frmMain.frx":0B7B
  288.             Key             =   "Paste"
  289.          EndProperty
  290.          BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  291.             Picture         =   "frmMain.frx":0C8D
  292.             Key             =   "Delete"
  293.          EndProperty
  294.          BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  295.             Picture         =   "frmMain.frx":0D9F
  296.             Key             =   "Bold"
  297.          EndProperty
  298.          BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  299.             Picture         =   "frmMain.frx":0EB1
  300.             Key             =   "Italic"
  301.          EndProperty
  302.          BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  303.             Picture         =   "frmMain.frx":0FC3
  304.             Key             =   "Underline"
  305.          EndProperty
  306.          BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  307.             Picture         =   "frmMain.frx":10D5
  308.             Key             =   "Find"
  309.          EndProperty
  310.          BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  311.             Picture         =   "frmMain.frx":11E7
  312.             Key             =   "Align Left"
  313.          EndProperty
  314.          BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  315.             Picture         =   "frmMain.frx":12F9
  316.             Key             =   "Center"
  317.          EndProperty
  318.          BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  319.             Picture         =   "frmMain.frx":140B
  320.             Key             =   "Align Right"
  321.          EndProperty
  322.          BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  323.             Picture         =   "frmMain.frx":151D
  324.             Key             =   "Justify"
  325.          EndProperty
  326.       EndProperty
  327.    End
  328.    Begin MSComctlLib.Toolbar tbFind 
  329.       Align           =   1  'Align Top
  330.       Height          =   630
  331.       Left            =   0
  332.       TabIndex        =   3
  333.       Top             =   360
  334.       Visible         =   0   'False
  335.       Width           =   9090
  336.       _ExtentX        =   16034
  337.       _ExtentY        =   1111
  338.       ButtonWidth     =   609
  339.       ButtonHeight    =   953
  340.       AllowCustomize  =   0   'False
  341.       Appearance      =   1
  342.       _Version        =   393216
  343.       Begin VB.CommandButton cmdFindNext 
  344.          Caption         =   "Find Next"
  345.          Height          =   330
  346.          Left            =   4635
  347.          TabIndex        =   6
  348.          Top             =   225
  349.          Width           =   960
  350.       End
  351.       Begin VB.CommandButton cmdFind 
  352.          Caption         =   "Find"
  353.          Height          =   330
  354.          Left            =   3735
  355.          TabIndex        =   5
  356.          Top             =   225
  357.          Width           =   780
  358.       End
  359.       Begin VB.TextBox Text1 
  360.          Height          =   330
  361.          Left            =   45
  362.          TabIndex        =   4
  363.          Top             =   225
  364.          Width           =   3570
  365.       End
  366.    End
  367.    Begin VB.Menu mnuFile 
  368.       Caption         =   "&File"
  369.       Begin VB.Menu mnuFileNew 
  370.          Caption         =   "&New"
  371.          Shortcut        =   ^N
  372.       End
  373.       Begin VB.Menu mnuFileOpen 
  374.          Caption         =   "&Open..."
  375.          Shortcut        =   ^O
  376.       End
  377.       Begin VB.Menu mnuFileSep1 
  378.          Caption         =   "-"
  379.       End
  380.       Begin VB.Menu mnuFileSave 
  381.          Caption         =   "&Save"
  382.       End
  383.       Begin VB.Menu mnuFileSaveAs 
  384.          Caption         =   "Save &As..."
  385.          Shortcut        =   ^A
  386.       End
  387.       Begin VB.Menu mnuFileSep2 
  388.          Caption         =   "-"
  389.       End
  390.       Begin VB.Menu mnuFilePrint 
  391.          Caption         =   "&Print..."
  392.          Shortcut        =   ^P
  393.       End
  394.       Begin VB.Menu mnuFileSep3 
  395.          Caption         =   "-"
  396.       End
  397.       Begin VB.Menu mnuFileExit 
  398.          Caption         =   "E&xit"
  399.       End
  400.    End
  401.    Begin VB.Menu mnuEdit 
  402.       Caption         =   "&Edit"
  403.       Begin VB.Menu mnuEditDelete 
  404.          Caption         =   "&Delete"
  405.          Shortcut        =   {DEL}
  406.       End
  407.       Begin VB.Menu mnuEditSep1 
  408.          Caption         =   "-"
  409.       End
  410.       Begin VB.Menu mnuEditCut 
  411.          Caption         =   "Cu&t"
  412.          Shortcut        =   ^X
  413.       End
  414.       Begin VB.Menu mnuEditCopy 
  415.          Caption         =   "&Copy"
  416.          Shortcut        =   ^C
  417.       End
  418.       Begin VB.Menu mnuEditPaste 
  419.          Caption         =   "&Paste"
  420.          Shortcut        =   ^V
  421.       End
  422.       Begin VB.Menu mnuEditSep2 
  423.          Caption         =   "-"
  424.       End
  425.       Begin VB.Menu mnuEditFind 
  426.          Caption         =   "&Find"
  427.          Shortcut        =   ^F
  428.       End
  429.       Begin VB.Menu mnuEditFindNext 
  430.          Caption         =   "Find Next"
  431.          Shortcut        =   {F3}
  432.       End
  433.       Begin VB.Menu mnuEditSep3 
  434.          Caption         =   "-"
  435.       End
  436.       Begin VB.Menu mnuEditSelectAll 
  437.          Caption         =   "Select &All"
  438.       End
  439.       Begin VB.Menu mnuEditTimeDate 
  440.          Caption         =   "Time/Date"
  441.          Shortcut        =   {F5}
  442.       End
  443.    End
  444.    Begin VB.Menu mnuFonts 
  445.       Caption         =   "F&onts"
  446.       Begin VB.Menu mnuFontsBold 
  447.          Caption         =   "&Bold"
  448.       End
  449.       Begin VB.Menu mnuFontsItalic 
  450.          Caption         =   "&Italic"
  451.       End
  452.       Begin VB.Menu mnuFontsUnderline 
  453.          Caption         =   "&Underline"
  454.       End
  455.       Begin VB.Menu mnuFontsSep1 
  456.          Caption         =   "-"
  457.       End
  458.       Begin VB.Menu mnuFontsFont 
  459.          Caption         =   "&Font..."
  460.       End
  461.       Begin VB.Menu mnuFontsColor 
  462.          Caption         =   "&Color..."
  463.       End
  464.    End
  465.    Begin VB.Menu mnuView 
  466.       Caption         =   "&View"
  467.       Begin VB.Menu mnuViewToolbar 
  468.          Caption         =   "&Toolbar"
  469.          Checked         =   -1  'True
  470.       End
  471.       Begin VB.Menu mnuViewStatusBar 
  472.          Caption         =   "Status &Bar"
  473.          Checked         =   -1  'True
  474.       End
  475.    End
  476.    Begin VB.Menu mnuHelp 
  477.       Caption         =   "&Help"
  478.       Begin VB.Menu mnuHelpAbout 
  479.          Caption         =   "&About "
  480.       End
  481.    End
  482. Attribute VB_Name = "frmMain"
  483. Attribute VB_GlobalNameSpace = False
  484. Attribute VB_Creatable = False
  485. Attribute VB_PredeclaredId = True
  486. Attribute VB_Exposed = False
  487. Option Explicit
  488. Dim DocChanged As Boolean
  489. Dim docname As String
  490. Private Sub cmdFind_Click()
  491. Dim textfound As Integer
  492.     ' Enables the cmdFindNext
  493. cmdFindNext.Enabled = True
  494.     ' Finds the text in the search box and highlights it,
  495.     ' then sets the focus on the richtextbox so the selected
  496.     ' text is editable.
  497. RichTextBox1.Find (Text1.Text)
  498. RichTextBox1.SetFocus
  499.     ' The richtextbox1.find method returns an integer
  500.     ' value of -1 if the searched for text is not found.
  501.     ' If this is true then it displays a message box.
  502. textfound = RichTextBox1.Find(Text1.Text)
  503. If textfound = -1 Then
  504. MsgBox "End of Document" & vbCr & "Text Not Found", vbInformation, _
  505.     App.Title
  506. End If
  507. End Sub
  508. Private Sub cmdFindNext_Click()
  509. mnuEditFindNext_Click
  510. End Sub
  511. Private Sub Form_Activate()
  512.     ' Updates toolbar and menus.
  513. ChangeToolBar
  514. ChangeMenus
  515. End Sub
  516. Private Sub Form_Load()
  517. Dim LineWidth As Long
  518.     ' Updates toolbar and menus.
  519. ChangeToolBar
  520. ChangeMenus
  521.     ' Tell the RichTextBox to base it's display off of the printer,
  522.     ' and gives a 1 inch border all around.
  523. LineWidth = WYSIWYG_RTF(RichTextBox1, 1440, 1440)
  524.     ' Set the form width to match the line width of printer.
  525.     ' Plus a little to keep the scroll bar from showin up.
  526. Me.Width = LineWidth + 300
  527.     ' Center the form in middle of screen.
  528. Me.Move (Screen.Height - Me.Height) / 2, (Screen.Width - Me.Width) / 2
  529. docname = " (Untitled)"
  530. Me.Caption = App.Title & docname
  531.     ' Disables the Find and FindNext buttons
  532. cmdFind.Enabled = False
  533. cmdFindNext.Enabled = False
  534. End Sub
  535. Private Sub Form_Resize()
  536.     ' Position the RTF on form,
  537.     ' taking into consideration the size of Toolbar and Status bar.
  538. RichTextBox1.Move 0, 420, Me.ScaleWidth, Me.ScaleHeight - 690
  539. End Sub
  540. Private Sub Form_Unload(cancel As Integer)
  541.     ' Checks to see if document has changed since last save,
  542.     ' and if it has gives a message box with a chance to save.
  543. If DocChanged Then
  544.     Select Case MsgBox("The file has changed." & vbCr & vbCr & _
  545.             "Do you wish to save your changes?", _
  546.             vbExclamation + vbYesNoCancel, frmMain.Caption)
  547.     Case vbYes
  548.         mnuFileSave_Click
  549.     Case vbNo
  550.         Unload frmMain
  551.     Case vbCancel
  552.         cancel = True
  553.     End Select
  554. End If
  555. End Sub
  556. Private Sub mnuEditDelete_Click()
  557. DeleteSelectedText
  558.     'Updates toolbar and menus.
  559. ChangeToolBar
  560. ChangeMenus
  561. End Sub
  562. Private Sub mnuEditFind_Click()
  563.     ' This routine shows the Find Toolbar.
  564.     ' And resizes the richtextbox depending on whether or not the
  565.     ' standard toolbar is shown.
  566. If tbFind.Visible = False Then
  567.     tbFind.Visible = True
  568.         If tbToolBar.Visible = False Then
  569.             RichTextBox1.Move 0, 630, Me.ScaleWidth, Me.ScaleHeight - 900
  570.         Else
  571.             RichTextBox1.Move 0, 1050, Me.ScaleWidth, Me.ScaleHeight - 1320
  572.         End If
  573.     ' This routine hides the Find Toolbar.
  574.     ' And resizes the richtextbox dependin on whether or not the
  575.     ' standard toolbar is shown.
  576.     tbFind.Visible = False
  577.         If tbToolBar.Visible = False Then
  578.             RichTextBox1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight - 270
  579.         Else
  580.             RichTextBox1.Move 0, 420, Me.ScaleWidth, Me.ScaleHeight - 690
  581.         End If
  582. End If
  583. End Sub
  584. Private Sub mnuEditFindNext_Click()
  585.     ' Set the focus so the selected text can be directly edited.
  586. RichTextBox1.SetFocus
  587.     ' Finds the next instance of the word, starting from
  588.     ' the selected text.
  589. RichTextBox1.Find (Text1.Text), RichTextBox1.SelStart + 1
  590. End Sub
  591. Private Sub mnuEditSelectAll_Click()
  592.     ' Selects all the text in the current document.
  593. RichTextBox1.SelStart = 0
  594. RichTextBox1.SelLength = Len(RichTextBox1.Text)
  595.     ' Updates the toolbar and menus.
  596. ChangeToolBar
  597. ChangeMenus
  598. End Sub
  599. Private Sub mnuEditTimeDate_Click()
  600. Dim Text As String
  601. Dim SelStart As Long
  602.     ' Deletes the selected text, if any, and gets ready to insert
  603.     ' the time and date string.
  604. DeleteSelectedText
  605. If RichTextBox1.SelLength > 0 Then
  606. End If
  607.     ' Inserts time and date.
  608. Text = RichTextBox1.Text
  609. SelStart = RichTextBox1.SelStart
  610. RichTextBox1.Text = Left(Text, SelStart) & Now & _
  611.         Right(Text, Len(Text) - SelStart)
  612.     ' Resets cursor to original position.
  613. RichTextBox1.SelStart = SelStart
  614.     ' Updates toolbar and menus.
  615. ChangeToolBar
  616. ChangeMenus
  617. End Sub
  618. Private Sub mnuFontsBold_Click()
  619.     ' Sets the Bold property and makes the menu context sensative.
  620. If RichTextBox1.SelBold Then
  621.     RichTextBox1.SelBold = False
  622.     mnuFontsBold.Checked = False
  623.     RichTextBox1.SelBold = True
  624.     mnuFontsBold.Checked = True
  625. End If
  626. End Sub
  627. Private Sub mnuFontsColor_Click()
  628.     ' Shows the color dialogue box and sets the current color.
  629. CDL1.Flags = cdlCCFullOpen
  630. CDL1.ShowColor
  631. RichTextBox1.SelColor = CDL1.Color
  632. End Sub
  633. Private Sub mnuFontsFont_Click()
  634.     ' Shows the Font dialogue box and sets the current font.
  635. CDL1.Flags = cdlCFBoth Or cdlCFEffects
  636. CDL1.ShowFont
  637. With RichTextBox1
  638.     .SelFontName = CDL1.FontName
  639.     .SelFontSize = CDL1.FontSize
  640.     .SelBold = CDL1.FontBold
  641.     .SelItalic = CDL1.FontItalic
  642.     .SelStrikeThru = CDL1.FontStrikethru
  643.     .SelUnderline = CDL1.FontUnderline
  644.     .SelColor = CDL1.Color
  645. End With
  646. End Sub
  647. Private Sub mnuFontsItalic_Click()
  648.     ' Sets the italic property and makes the menu context sensative.
  649. If RichTextBox1.SelItalic Then
  650.     RichTextBox1.SelItalic = False
  651.     mnuFontsItalic.Checked = False
  652.     RichTextBox1.SelItalic = True
  653.     mnuFontsItalic.Checked = True
  654. End If
  655.             
  656. End Sub
  657. Private Sub mnuFontsUnderline_Click()
  658.     ' Sets the underline property and makes the menu context sensative.
  659. If RichTextBox1.SelUnderline Then
  660.     RichTextBox1.SelUnderline = False
  661.     mnuFontsUnderline.Checked = False
  662.     RichTextBox1.SelUnderline = True
  663.     mnuFontsUnderline.Checked = True
  664. End If
  665. End Sub
  666. Private Sub RichTextBox1_Change()
  667.     ' Changes the docchanged value to true for saving purposes.
  668. DocChanged = True
  669.     ' Updates the toolbar and menus.
  670. ChangeToolBar
  671. ChangeMenus
  672. End Sub
  673. Private Sub RichTextBox1_Click()
  674.     ' Updates the toolbar and menus just in case.
  675. ChangeToolBar
  676. ChangeMenus
  677. End Sub
  678. Private Sub RichTextBox1_KeyUp(KeyCode As Integer, Shift As Integer)
  679.  ' Updates the toolbar and menus just in case.
  680. ChangeMenus
  681. ChangeToolBar
  682. End Sub
  683. Private Sub RichTextBox1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
  684. ' Updates the toolbar and menus just in case.
  685. ChangeMenus
  686. ChangeToolBar
  687. End Sub
  688. Private Sub tbToolBar_ButtonClick(ByVal Button As MSComctlLib.Button)
  689. On Error Resume Next
  690.     ' Just tells the toolbar buttons what to do...
  691.     Select Case Button.Key
  692.         
  693.         Case "New"
  694.             mnuFileNew_Click
  695.         
  696.         Case "Open"
  697.             mnuFileOpen_Click
  698.         
  699.         Case "Save"
  700.             mnuFileSave_Click
  701.         
  702.         Case "Print"
  703.             mnuFilePrint_Click
  704.         
  705.         Case "Cut"
  706.             mnuEditCut_Click
  707.         
  708.         Case "Copy"
  709.             mnuEditCopy_Click
  710.         
  711.         Case "Paste"
  712.             mnuEditPaste_Click
  713.         
  714.         Case "Delete"
  715.             mnuEditDelete_Click
  716.         
  717.         Case "Bold"
  718.             
  719.             mnuFontsBold_Click
  720.         
  721.         Case "Italic"
  722.             
  723.             mnuFontsItalic_Click
  724.                         
  725.         Case "Underline"
  726.             
  727.             mnuFontsUnderline_Click
  728.             
  729.         Case "Find"
  730.             
  731.             mnuEditFind_Click
  732.                     
  733.         Case "Align Left"
  734.             
  735.             ' Aligns text to left margin.
  736.             RichTextBox1.SelAlignment = rtfLeft
  737.         
  738.         Case "Center"
  739.             
  740.             'Aligns text to center.
  741.             RichTextBox1.SelAlignment = rtfCenter
  742.         
  743.         Case "Align Right"
  744.             
  745.             'Aligns text to right margin.
  746.             RichTextBox1.SelAlignment = rtfRight
  747. End Select
  748. End Sub
  749. Private Sub mnuHelpAbout_Click()
  750.     ' Simple message box for the About.
  751. MsgBox "Version " & App.Major & "." & App.Minor & "." & App.Revision
  752. End Sub
  753. Private Sub mnuViewStatusBar_Click()
  754.     ' Shows or hides the status bar as needed.
  755.     ' And makes the menu context sensative.
  756. mnuViewStatusBar.Checked = Not mnuViewStatusBar.Checked
  757. sbStatusBar.Visible = mnuViewStatusBar.Checked
  758. End Sub
  759. Private Sub mnuViewToolbar_Click()
  760.     ' Shows or hides the toolbar as needed.
  761.     ' And makes the menu context sensative.
  762. mnuViewToolbar.Checked = Not mnuViewToolbar.Checked
  763. tbToolBar.Visible = mnuViewToolbar.Checked
  764.     ' This resizes the richtextbox depending on the state of the toolbar.
  765. If tbToolBar.Visible = False Then
  766.     RichTextBox1.Move 0, 0, Me.ScaleWidth, Me.ScaleHeight - 270
  767.     RichTextBox1.Move 0, 420, Me.ScaleWidth, Me.ScaleHeight - 690
  768. End If
  769. End Sub
  770. Private Sub mnuEditPaste_Click()
  771. Dim Text As String
  772. Dim ClipboardText As String
  773. Dim SelStart As Long
  774. If Clipboard.GetFormat(vbCFText) Then
  775.     ' Replace selected text. (if any)
  776.     If RichTextBox1.SelLength > 0 Then
  777.         DeleteSelectedText
  778.     End If
  779.     ' Move text we need to a variable.
  780.     Text = RichTextBox1.Text
  781.     SelStart = RichTextBox1.SelStart
  782.     ClipboardText = Clipboard.GetText
  783.     ' Gather new text string and replace text box
  784.     ' contents with it.
  785.     RichTextBox1.Text = Left(Text, SelStart) & _
  786.             ClipboardText & Right(Text, Len(Text) - SelStart)
  787.     ' Restore the cursor position.
  788.     RichTextBox1.SelStart = SelStart
  789.     ChangeMenus
  790.     ChangeToolBar
  791. End If
  792. End Sub
  793. Private Sub mnuEditCopy_Click()
  794.     CopytoClipBoard
  795.     ChangeMenus
  796.     ChangeToolBar
  797. End Sub
  798. Private Sub mnuEditCut_Click()
  799.     CopytoClipBoard
  800.     DeleteSelectedText
  801.     ChangeMenus
  802.     ChangeToolBar
  803. End Sub
  804. Private Sub mnuFileExit_Click()
  805.     'unload the form
  806.     Unload Me
  807. End Sub
  808. Private Sub mnuFilePrint_Click()
  809. Dim bcancel As Boolean
  810. Dim ncopy As Integer
  811. On Error GoTo errorhandler
  812. bcancel = False
  813. CDL1.Flags = cdlPDHidePrintToFile Or _
  814.         cdlPDNoSelection Or cdlPDNoPageNums _
  815.         Or cdlPDCollate
  816. CDL1.CancelError = True
  817. CDL1.PrinterDefault = True
  818. CDL1.Copies = 1
  819. CDL1.ShowPrinter
  820. If bcancel = False Then
  821.     PrintRTF RichTextBox1, 1440, 1440, 1440, 1440
  822.     For ncopy = 1 To CDL1.Copies
  823.     Next ncopy
  824. End If
  825. Exit Sub
  826. errorhandler:
  827. If Err.Number = cdlCancel Then
  828. bcancel = True
  829. Resume Next
  830. End If
  831. End Sub
  832. Private Sub mnuFileSaveAs_Click()
  833. Dim cancel As Boolean
  834. On Error GoTo errorhandler
  835. cancel = False
  836. CDL1.DefaultExt = ".txt"
  837. CDL1.Filter = "Text Files (*.txt)|*.txt|RichText Files (*.rtf)|*.rtf|All Files (*.*)|*.*"
  838. CDL1.CancelError = True
  839. CDL1.Flags = cdlOFNHideReadOnly Or cdlOFNOverwritePrompt
  840. CDL1.ShowSave
  841. If Not cancel Then
  842.     If UCase(Right(CDL1.FileName, 3)) = "RTF" Then
  843.         RichTextBox1.SaveFile CDL1.FileName, rtfRTF
  844.     Else
  845.         RichTextBox1.SaveFile CDL1.FileName, rtfText
  846.     End If
  847.     RichTextBox1.FileName = CDL1.FileName
  848.     docname = CDL1.FileName
  849.     Me.Caption = App.Title & " " & docname
  850.     DocChanged = False
  851. End If
  852. Exit Sub
  853. errorhandler:
  854. If Err.Number = cdlCancel Then
  855.     cancel = True
  856.     Resume Next
  857. End If
  858. End Sub
  859. Private Sub mnuFileSave_Click()
  860. If docname = " (Untitled)" Then
  861.     mnuFileSaveAs_Click
  862.     If UCase(Right(RichTextBox1.FileName, 3)) = "RTF" Then
  863.         RichTextBox1.SaveFile RichTextBox1.FileName, rtfRTF
  864.     Else
  865.         RichTextBox1.SaveFile RichTextBox1.FileName, rtfText
  866.     End If
  867.     DocChanged = False
  868. End If
  869. End Sub
  870. Private Sub mnuFileOpen_Click()
  871. Dim cancel As Boolean
  872. On Error GoTo errorhandler
  873. cancel = False
  874. CDL1.Filter = "Text Files (*.txt)|*.txt|RichText Files (*.rtf)|*.rtf|All Files|*.*"
  875. CDL1.CancelError = True
  876. CDL1.Flags = cdlOFNHideReadOnly Or cdlOFNFileMustExist
  877. CDL1.ShowOpen
  878. If Not cancel Then
  879.     If UCase(Right(CDL1.FileName, 3)) = "RTF" Then
  880.         RichTextBox1.LoadFile CDL1.FileName, rtfRTF
  881.     Else
  882.         RichTextBox1.LoadFile CDL1.FileName, rtfText
  883.     End If
  884.         RichTextBox1.FileName = CDL1.FileName
  885.         docname = RichTextBox1.FileName
  886.         Me.Caption = App.Title & " " & docname
  887.         DocChanged = False
  888. End If
  889. Exit Sub
  890. errorhandler:
  891. If Err.Number = cdlCancel Then
  892.     cancel = True
  893.     Resume Next
  894. End If
  895. End Sub
  896. Private Sub mnuFileNew_Click()
  897. Dim cancel As Integer
  898. If DocChanged = False Then
  899.     RichTextBox1.Text = ""
  900.     Select Case MsgBox("The file has changed." & vbCr & vbCr & _
  901.             "Do you wish to save your changes?", _
  902.             vbExclamation + vbYesNoCancel, frmMain.Caption)
  903.     Case vbYes
  904.         mnuFileSave_Click
  905.     Case vbNo
  906.         RichTextBox1.Text = ""
  907.     Case vbCancel
  908.         cancel = True
  909.     End Select
  910. End If
  911. End Sub
  912. Public Sub ChangeMenus()
  913.     ' Makes the menus and toolbar context sensative.
  914. mnuFileSave.Enabled = DocChanged
  915. mnuFileSaveAs.Enabled = DocChanged
  916. mnuEditCopy.Enabled = False
  917. mnuEditCut.Enabled = False
  918. mnuEditDelete.Enabled = False
  919. mnuEditPaste.Enabled = False
  920. tbToolBar.Buttons("Save").Enabled = DocChanged
  921. If RichTextBox1.SelLength > 0 Then
  922.     mnuEditCut.Enabled = True
  923.     mnuEditCopy.Enabled = True
  924.     mnuEditDelete.Enabled = True
  925.     tbToolBar.Buttons("Cut").Enabled = True
  926.     tbToolBar.Buttons("Copy").Enabled = True
  927.     tbToolBar.Buttons("Delete").Enabled = True
  928.     mnuEditCut.Enabled = False
  929.     mnuEditCopy.Enabled = False
  930.     mnuEditDelete.Enabled = False
  931.     tbToolBar.Buttons("Cut").Enabled = False
  932.     tbToolBar.Buttons("Copy").Enabled = False
  933.     tbToolBar.Buttons("Delete").Enabled = False
  934. End If
  935. If Clipboard.GetFormat(vbCFText) Then
  936.     mnuEditPaste.Enabled = True
  937.     tbToolBar.Buttons("Paste").Enabled = True
  938.     mnuEditPaste.Enabled = False
  939.     tbToolBar.Buttons("Paste").Enabled = True
  940. End If
  941. If RichTextBox1.SelBold Then
  942.     mnuFontsBold.Checked = True
  943.     mnuFontsBold.Checked = False
  944. End If
  945. If RichTextBox1.SelItalic Then
  946.     mnuFontsItalic.Checked = True
  947.     mnuFontsItalic.Checked = False
  948. End If
  949. If RichTextBox1.SelUnderline Then
  950.     mnuFontsUnderline.Checked = True
  951.     mnuFontsUnderline.Checked = False
  952. End If
  953. End Sub
  954. Private Sub CopytoClipBoard()
  955.     ' Copies selected text to clipboard.
  956. Clipboard.SetText RichTextBox1.SelText
  957. End Sub
  958. Public Sub DeleteSelectedText()
  959.     ' Sets the value of the selected text to nothing.
  960. RichTextBox1.SelText = ""
  961. End Sub
  962. Public Sub ChangeToolBar()
  963.     ' Makes portions of the tool bar context sensative.
  964. If RichTextBox1.SelBold Then
  965.     tbToolBar.Buttons("Bold").Value = tbrPressed
  966.     tbToolBar.Buttons("Bold").Value = tbrUnpressed
  967. End If
  968. If RichTextBox1.SelItalic Then
  969.     tbToolBar.Buttons("Italic").Value = tbrPressed
  970.     tbToolBar.Buttons("Italic").Value = tbrUnpressed
  971. End If
  972. If RichTextBox1.SelUnderline Then
  973.     tbToolBar.Buttons("Underline").Value = tbrPressed
  974.     tbToolBar.Buttons("Underline").Value = tbrUnpressed
  975. End If
  976. End Sub
  977. Private Sub Text1_Change()
  978.     ' Enables the find button when the search text is entered.
  979. cmdFind.Enabled = True
  980. End Sub
  981.